<template>
  <a-modal v-model:visible="visible" title="新增供货商信息" @ok="execAdd">
    <!-- 新增窗口 -->
    <a-form
      :model="addObj"
      :label-col="{ span: 5 }"
      :wrapper-col="{ span: 14 }"
    >
      <a-form-item label="货物编号">
        <a-input v-model:value="addObj.ca_id" />
      </a-form-item>
      <a-form-item label="分类编号">
        <a-input v-model:value="addObj.ty_id" />
      </a-form-item>
      <a-form-item label="货物名称">
        <a-input v-model:value="addObj.ca_name" />
      </a-form-item>
      <a-form-item label="单位">
        <a-input v-model:value="addObj.ca_unit" />
      </a-form-item>
      <a-form-item label="保质期（天）">
        <a-input v-model:value="addObj.ca_date" />
      </a-form-item>
      <a-form-item label="预售价">
        <a-input v-model:value="addObj.ca_price" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>
<script>
import { ref, reactive } from "vue";
import { get, put, post, tip, del } from "@/common";
export default {
  setup(props, { emit }) {
    const addObj = reactive({
      ca_id: "",
      st_id: "",
      ty_id: "",
      ca_name: "",
      ca_unit: "",
      ca_date: "",
      ca_price: "",
    });
    const visible = ref(false);
    const openAdd = () => {
      visible.value = true;
    };
    const execAdd = () => {
      post("/stock/maintenance", addObj).then((res) => {
        (addObj.ca_id = ""),
          (addObj.st_id = ""),
          (addObj.ty_id = ""),
          (addObj.ca_name = ""),
          (addObj.ca_unit = ""),
          (addObj.ca_date = ""),
          (addObj.ca_price = ""),
          (visible.value = false);
        tip.success("新增成功");
        emit("flash");
      });
    };
    return {
      openAdd,
      addObj,
      visible,
      execAdd,
    };
  },
};
</script>
<style scoped>
</style>